<include file="public:headtop" />
<style>
  body{color:#ccc;}
  #content{
    padding-top:15px;
    background:#ffffed;
    margin:10px;
    border-radius: 7px
  }
  #content .cart_list li {
    border-width:0px;
    background:none;
  }

  #content .order_address_list{
    padding:0px;
    background:none;
    border-width:0px;
    box-shadow: none;
  }

  #content .message_box{
    background:none;
    border-width:0px;
    box-shadow: none;
  }

  .goods_info img{
      border:3px solid #ffbe00;
  }
  .goods_info .tit{
    color:#cdc8c8;
  }
</style>


<div id="content">
  <if condition="$order_type eq 'wosong'">
  <img style="width:100%" class="mt10" src="/static/weixin/images/index/send_bf_title.png" alt="">
  </if>
    <!-- <h4 class="add_title"><a class="enter" href="{:u('user/address',array('spid'=>$aspid))}">管理收货地址</a></h4> -->
  

    <ul class="cart_list">
         <volist name='item' id='vo'>
             <li id="cart_item_{$vo.id}">
                  <p class="goods_info">
                      <span class="img"><a href="{:u('item/index',array('id'=>$vo['id'],'spid'=>$aspid))}" ><img src="{:attach(get_thumb($vo['img'], '_m'), 'item')}" height="80" width="80"></a></span>
                      <span class="tit">
                          <a href="{:u('item/index',array('id'=>$vo['id'],'spid'=>$aspid))}" >{$vo.name}</a>
                      </span>
                  </p>
                         
              </li>
              </volist>
        </ul>



    <div class="order_address_list">
        <script type="text/javascript" src="__STATIC__/weixin/js/mlselection.js" charset="utf-8"></script>
         <!-- <script type="text/javascript" src="__STATIC__/weixin/js/area.js" charset="utf-8"></script>-->
        <script type="text/javascript" src="__STATIC__/weixin/js/jquery_003.js" charset="utf-8"></script>
        <script type="text/javascript" src="__STATIC__/weixin/js/dialog.js" id="dialog_js" charset="utf-8"></script>
        <link href="__STATIC__/weixin/css/dialog.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="__STATIC__/weixin/js/jquery.js" id="dialog_js" charset="utf-8"></script>
        <script type="text/javascript" language="javascript" src='__STATIC__/weixin/js/dizhi2.js'></script>
<script>
  var PCAD = "{$address_str}";
</script>
<script type="text/javascript" language="javascript" src='__STATIC__/weixin/js/diqu2.js'></script>
        <script>
        var order_type = "{$order_type}";
        if(order_type == 'wosong'){
            $(".order_address_list,.add_title").hide()
        }
        $(function(){
        	$('input[name=address_options]').change(function(){
        		if($(this).val()==0)
        		{
        			$('#address_form').show();
        		}else
        		{
        			$('#address_form').hide();
        		}
        	});
        	set_address();
        })

        function set_address()
        {
        	var addr_id = $("input[name='address_options']:checked").val();

        	if(addr_id == 0)
        	{

        		$('#address_form').show();
        	}
        	else
        	{
        		$('#address_form').hide();

        	}
        }

        function ordertj()
        {
        	var addr_id = $("input[name='address_options']:checked").val();
        	if(addr_id == 0 && order_type != 'wosong')
        	{
        		var consignee=  $.trim($('#consignee').val());
        		var address=  $.trim($('#address').val());
        		var phone_mob=  $.trim($('#phone_mob').val());
        		var sheng=  $.trim($('#s1').val());

        		if(consignee=='')
        		{
        			alert('请输入收货人姓名');
        			return false;
        		}
        		if(sheng=='')
        		{
        			alert('请选择所在地区');return false;
        		}

        		if(address=='')
        		{
        			alert('请输入详细地址');
        			return false;
        		}
        		if(phone_mob=='')
        		{
        			alert('请输入手机号码');
        			return false;
        		}
        		if(isNaN(phone_mob))
        		{
        			alert('请输入正确的手机号码');return false;
        		}
        	}
        	$('#order_form').submit();

        }
        </script>

      
      <div class="mb20"><img src="__STATIC__/weixin/images/index/address_title.png" alt="" class='w100'></div>
       <form method="POST"  action="{:u('order/pay')}" id="order_form" name="order_form"   >
        
        <?php if(count($address_list)!=0){ ?>
        
        <volist name='address_list' id='vo' >
        <ul class="receive_add address_item selected_address">
            <li class="radio"><input id="address_{$vo.id}" checked="checked"  name="address_options" value="{$vo.id}" type="radio"></li>
            <li class="particular">{$vo.sheng}&nbsp;{$vo.shi}&nbsp;{$vo.qu}&nbsp;{$vo.address}</li>
            <li class="name">收货人姓名: {$vo.consignee}</li>
            <li class="mobile">手机号码:{$vo.mobile}</li>
        </ul>
       </volist>
        <ul class="new_receive_add address_item">
            <li class="radio">
            <input name="address_options" id="use_new_address" value="0"  type="radio">
            </li><li class="particular">使用新的收货地址</li>
        </ul>    
           
        <ul style="display: none;" class="fill_in_content" id="address_form">
            <!-- <li>
                <p class="title">收货人姓名</p>
                <p><input value="" name="consignee" id="consignee" class="text" type="text"></p>
            </li> -->
            <li>
                <!-- <p class="title">所在地区</p>
                <p></p> -->
                <div id="region">
                 <select name="sheng" id="s1"></select>
                <select name="shi" id="s2"></select>
                <select name="qu" id="s3"></select>
                <select name="business_area"><option value="">--请选择商圈--</option></select>
                <select name="building"><option value="">--请选择大厦--</option></select>
                </div>
                	<script language="javascript">
								new PCAS("sheng","shi","qu","","","");
			</script>
                <p></p>
            </li>

            <li>
                <p class="title mt10">收货人：
                <input value="" name="consignee" id="consignee" class="text" type="text">
                </p>
            </li>
            <li>
                <p class="title">门牌号：
                <input value="" name="address" id="address" class="text width1" type="text">
                </p>
            </li>
            <li>
                <p class="title">手机号：<input id="phone_mob" name="phone_mob" class="text" type="text"></p>
            </li>
            <li>
                <p class="title">&nbsp;</p>
                <!-- <p>
                    <label>
                        <input value="1" id="save_address" name="save_address" type="checkbox" checked>&nbsp;自动保存收货地址
                        <span class="explain">&nbsp;(&nbsp;选择后该地址将会保存到您的收货地址列表&nbsp;)&nbsp;</span>
                    </label>
                </p> -->
            </li>
        </ul>
        <?php }else{ ?>
           <ul class="new_receive_add address_item">
            <li class="radio">
            <input checked='checked' name="address_options" id="use_new_address" value="0"  type="radio">
            </li><li class="particular">使用新的收货地址</li>
            </ul> 
       
        <ul  class="fill_in_content" id="address_form">
            <!-- <li>
                <p class="title">收货人姓名</p>
                <p><input value="" name="consignee" id="consignee" class="text" type="text"></p>
            </li> -->
            <li>
                <!-- <p class="title">所在地区</p>
                <p></p> -->
                <div id="region">
                 <select name="sheng" id="s1"></select>
                <select name="shi" id="s2"></select>
                <select name="qu" id="s3"></select>
                <select name="business_area"><option value="">--请选择商圈--</option></select>
                <select name="building"><option value="">--请选择大厦--</option></select>
                </div>
                	<script language="javascript">
								      new PCAS("sheng","shi","qu","","","");
			           </script>
                <p></p>
            </li>

            <li>
                <p class="title mt10">收货人：
                <input value="" name="consignee" id="consignee" class="text" type="text">
                </p>
            </li>
            <li>
                <p class="title">门牌号：<input value="" name="address" id="address" class="text width1" type="text"></p>
            </li>
            <li>
                <p class="title">手机号：<input id="phone_mob" name="phone_mob" class="text" type="text"></p>
                <!-- <p><input value="" id="phone_mob" name="phone_mob" class="text" type="text"></p> -->
            </li>
            <li>
                <p class="title">&nbsp;</p>
                <!-- <p>
                    <label>
                        <input value="1" id="save_address" name="save_address" type="checkbox">&nbsp;自动保存收货地址
                        <span class="explain">&nbsp;(&nbsp;选择后该地址将会保存到您的收货地址列表&nbsp;)&nbsp;</span>
                    </label>
                </p> -->
            </li>
        </ul>
        <?php } ?>
        
    </div>			
    <!-- <div class="order_delivery">
     <?php if($freesum<=0) {?>
     卖家承担运费
     <?php }else{ ?>
        <h4 class="add_title">配送方式</h4>
        <div class="fashion_list">
        <volist name='freearr' id='vo' key='k' >
              <ul class="receive_add" shipping_id="{$vo.value}">
                  <li class="radio"><input id="{$vo.price}" <if condition='$k eq 1'>checked="checked"</if>  name="shipping_id" value="{$vo.value}" type="radio"></li>
                  <li class="fashion">
                  <switch name="vo.value">
                  <case value="1">平邮</case>
                  <case value="2">快递</case>
                  <default />EMS
                  </switch>
                  </li>
                  <li class="pay">配送费用:&nbsp;<span class="money" ectype="shipping_fee">¥{$vo.price}</span></li>
                  <li class="explain"></li>
                  <input type="hidden" id="price_{$vo.value}" value="{$vo.price}" >
              </ul>
        </volist>
            <!--   <ul class="receive_add" shipping_id="2">
                  <li class="radio"><input checked="checked" name="shipping_id" value="2" type="radio"></li>
                  <li class="fashion">快递</li>
                  <li class="pay">配送费用:&nbsp;<span class="money" ectype="shipping_fee">¥0.01</span></li>
                  <li class="explain"></li>
              </ul>
               <ul class="receive_add" shipping_id="3">
                  <li class="radio"><input checked="checked" name="shipping_id" value="3" type="radio"></li>
                  <li class="fashion">EMS</li>
                  <li class="pay">配送费用:&nbsp;<span class="money" ectype="shipping_fee">¥0.01</span></li>
                  <li class="explain"></li>
              </ul>-->
<!--         </div>
        <?php } ?> -->
    <!-- </div> -->
    <!-- <div class="message_box">
        <script type="text/javascript">
        function postscript_activation(tt){
        	if (!tt.name)
        	{
        		tt.value    = '';
        		tt.name = 'postscript';
        	}

        }
        </script>
        <span class="add_title">给卖家的附言</span>
        <div class="message">
            <textarea id="postscript"  onclick="postscript_activation(this);"></textarea>
        </div>
    </div> --> 
    
    <div class="make_sure">
        <p class="order_amount">订单总价：<strong class="fontsize3" id="order_amount">¥<font id='order_amount2'>{$sumPrice}</strong><input class="btn1" onClick="$(this).parent('p').next().toggle();$('#coupon_sn').val('');" style="display:none" type="button"></p>
  

        <div class='p15'>
              <if condition="$coupons">
              <div class="sel_wrap mb30">
                <label for="">请选择优惠券</label>
              <select class="select" name="coupon" id="coupon">
                <volist name="coupons" id="item">
                  <option value="{$item.id}">{$item.title}</option>
                </volist>
              </select>
            </div>
            </if>
            <if condition="$order_type eq 'songwo'">
              <div id="content" style="min-height:1px">
                <img onclick="window.location.href='{:u('user/addaddress')}'" src="/static/weixin/images/index/open_btn.png" style="width:40%">
                <img onClick="ordertj();" id='submit-address-btn' src="/static/weixin/images/index/submit_btn.png" style="margin-left:18%;width:40%">
              </div>
            <else/>
              <img onClick="ordertj();" id='submit-address-btn' src="/static/weixin/images/index/payforta.png" style="width:100%;">
            </if>
            <!-- <a href="{:u('shopcart/index',array('spid'=>$aspid))}" class="back">返回购物车</a> -->
        </div>
    </div>
    
    <input type="hidden" id="summoney" value="{$sumPrice}" />
    </form>

</div>
<include file="public:footer" />
</body>
</html>


  <script>
		     // $(function(){
		    
       //  	 $('input[name=shipping_id]').change(function(){
       //  	  if($(this).val()!=null)
       //  	  {
        	  
       //  	    var sumPrice=$('#summoney').val();
       //      	var freePrice= $('#price_'+$(this).val()).val();
       //      //alert(sumPrice);
       //      //	return false;
       //      	$('#order_amount2').html(Number(freePrice)+Number(sumPrice));
       //  	  }
       //  	 });
       //  	 set_free();

       //  })
        
       //    function set_free()
       //    {
       //    	var addr_id = $("input[name='shipping_id']:checked").val();
       //    //	 var addr_id =$("input[name=shipping_id]").find("option:checked").val();
          	
       //     if(addr_id !=null)
       //      {          
       //      	var sumPrice='{$sumPrice}';
       //      	var freePrice= $('#price_'+addr_id).val();
       //      	$('#order_amount2').html(Number(freePrice)+Number(sumPrice));
       //      }
       //      else
       //      {
       //      $('#order_amount2').html('{$sumPrice}');
       //      }
       //    }
		    </script>

        <script type="text/javascript">
       $(function(){
        $('#order_form').validate({
          errorPlacement: function(error, element){
            $(element).next("label").append(error);
          },
          success       : function(label){
            //label.addClass('validate_right').text('OK!');
          },
          onsubmit:true,// 是否在提交是验证
          onkeyup : false,
          rules : {
            consignee : {
              required : true,
            },
            address : {
              required : true
            },

          },
          messages : {
            consignee : {
              required : '您必须提供一个用户名',
              remote   : '用户名不存在！'
            },
            address  : {
              required : '请如实填写收货人详细地址'
            }
          }
        });
       });
        </script>